package com.tarena.lbs.user.pojo.query;

import com.tarena.lbs.base.protocol.pager.BasePageQuery;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;

import java.io.Serializable;

@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class AdminQuery extends BasePageQuery implements Serializable {

    @Schema(description  = "手机号")
    String accountPhone;

    @Schema(description  = "用户名")
    String nickname;
    
    @Schema(description = "商家ID")
    Integer businessId;
    
    // 兼容前端传递的 phone 参数名
    public void setPhone(String phone) {
        this.accountPhone = phone;
    }
    
    public String getPhone() {
        return this.accountPhone;
    }
    
    // 兼容前端传递的 username 参数名
    public void setUsername(String username) {
        this.nickname = username;
    }
    
    public String getUsername() {
        return this.nickname;
    }
    
    // 兼容前端传递的 storename 参数名
    public void setStorename(String storename) {
        try {
            this.businessId = Integer.parseInt(storename);
        } catch (NumberFormatException e) {
            // 如果转换失败，则不设置businessId
        }
    }
    
    public String getStorename() {
        if (this.businessId != null) {
            return String.valueOf(this.businessId);
        }
        return null;
    }
}